import {ref,onMounted} from 'vue'
import {get} from './request.ts'

export function useOrderInfoApi(url:string,method:string,data?:any){
    const response = ref(null)
    const error:any = ref(null)

    const fatchData = async ()=>{
        try{
            let resquest
            switch(method){
                case 'get':
                    resquest = await get(url,data)
                    break;
                default:
                    throw new Error('错误')
            }
            response.value = resquest.data;
        }catch(err){
            error.value = err
        }
    }
    return {response,error,fatchData}
}